<%@ page language="java" pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ include file="../../common/common.jsp" %>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>添加/编辑广告 - ${title }</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/js/uploadify/uploadify.css">
</head>
<body
        <%@ include file="../../common/skin.jsp" %>
>
<%@ include file="../../common/head.jsp" %>
<%@ include file="../../common/menu.jsp" %>
<div class="J_content">
    <div class="mt20 plr20">
        <div class="J_filter">
            <table class="not_hightlight" style="width: 100%;">
                <tbody>
                <tr>
                    <td class="t_right">
                        <div class="fr">
                            <a href="javascript:myBack()">
                                <i class="icon"></i><span>返回上一页</span>
                            </a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="J_formTable l_form_table mgt40">
            <form action="${ctx}/channel/association/saveorupdate" id="editForm" method="post">
                <input type="hidden" name="id" value="${association.id }"/>
                <input type="hidden" name="logo" id="logo" value="${association.logo }"/>
                <table>
                    <tr>
                        <td class="l_title w200">协会名称：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                <div class="t_text ml10 " style="min-width:200px">
                                    <label>
                                        <input type="text" name="name" value="${association.name }">
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td class="l_title w200">图片：<a href="${ctx }/cms/article/flashView" target="_blank"><font
                                color="red">无法上传？</font></a></td>
                        <td>
                            <div class="J_toolsBar fl">
                                <div class=" w200 ml10">
                                    <label>
                                        <input type="file" id="attachImage"/>
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="l_title"></td>
                        <td>
                            <div class="J_toolsBar fl">
                                <div class="t_img w100 ml10">
                                    <c:choose>
                                        <c:when test="${association.logo != null}">
                                            <img src="${ctx }${association.logo}" id="attachURL" width="100px"
                                                 height="100px"/>
                                        </c:when>
                                        <c:otherwise>
                                            <img src="${ctx }/static/images/J_null.png" id="attachURL" width="100px"
                                                 height="100px"/>
                                        </c:otherwise>
                                    </c:choose>

                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr id="orderNoTr">
                        <td class="l_title w200">会长：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                <div class="t_text w200 ml10">
                                    <label>
                                        <input type="text" name="president" value="${association.president }">
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td class="l_title w200">副会长：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                <div class="t_text w200 ml10">
                                    <label>
                                        <input type="text" name="vicePresident" value="${association.vicePresident }">
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="l_title w200">秘书长：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                <div class="t_text w200 ml10">
                                    <label>
                                        <input type="text" name="secretaryGeneral"
                                               value="${association.secretaryGeneral }">
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td class="l_title w200">办公地址：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                        <textarea name="address"
                                                  style="height:40px;width: 600px">${association.address }</textarea>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td class="l_title w200">排序：</td>
                        <td>
                            <div class="J_toolsBar fl" style="min-width:200px">
                                <div class="t_text w200 ml10">
                                    <label>
                                        <input type="text" name="sort"
                                               value="${association.sort }">
                                    </label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="2">
                            <div class="J_toolsBar mgt40">
                                <div class="t_buttonGroup">
                                    <a class="abtn red" href="javascript:mySubmit();">
                                        <i class="icon"></i>保存
                                    </a>
                                    <a class="abtn gray" href="javascript:myBack();">
                                        <i class="icon"></i>返回
                                    </a>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>

            </form>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/static/js/uploadify/jquery.uploadify.js"></script>
<script type="text/javascript">
    //表单验证
    $(function () {
        $('#editForm').validator({
            valid: function (form) {
                $('#editForm').ajaxSubmit({
                    success: function (result) {
                        if (result.success) {
                            layer.alert('保存成功');
                            window.location.href = "${ctx}/channel/association/list"
                        }
                    }
                });
            }
        });
    });

    function myBack() {
        window.location.href = "${ctx}/channel/association/list";
    }

    function mySubmit() {
        $('#editForm').submit();
    }

    $(function () {

        $("#rootColumnId").trigger("change")
        var articleType = '${article.type}';
        if (articleType == 1) {
            $('#contentTr').hide();
            $("#orderNoTr").hide();
            $("#hrefTr").show();
        } else if (articleType == 2) {
            $('#contentTr').hide();
            $("#orderNoTr").show();
            $("#hrefTr").show();
        }
    });

    $("#attachImage").uploadify(
        {
            'swf': '${pageContext.request.contextPath}/static/js/uploadify/uploadify.swf',
            'uploader': '${pageContext.request.contextPath}/upload/uploadAttach',
            'cancelImg': '${pageContext.request.contextPath}/static/js/uploadify/uploadify-cancel.png',
            'queueID': 'fileQueue',
            'auto': true,
            'multi': false,
            'simUploadLimit': 1,
            'buttonText': '上传图片',
            'fileObjName': 'fileData',
            'width': 70,
            'height': 20,
            'uploadLimit': 3,
            'onUploadSuccess': function (file, data, response) {
                if (data != null) {
                    var attachUrl = '${pageContext.request.contextPath}' + data;
                    $("#attachURL").attr('src', attachUrl);
                    $("#logo").val(data);
                }
            }
        });

    $('input[name="articleType"]').on('click', function () {
        var val = $('input[name="articleType"]:checked').val();
        if (val == 'contentType') {
            $('#contentTr').show();
            $("#hrefTr").hide();
            $("#orderNoTr").hide();
        } else if (val == 'hrefType') {
            $('#contentTr').hide();
            $("#orderNoTr").hide();
            $("#hrefTr").show();
        } else if (val == 'adType') {
            $('#contentTr').hide();
            $("#orderNoTr").show();
            $("#hrefTr").show();
        }
    });
</script>

</body>
</html>